/**
 * 
 */
package com.yangtao.prototype.system.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

import com.yangtao.framework.hibernate.BaseEntity;

/**
 * 用户角色类
 * 
 * @author 杨涛
 * 
 */
@Entity
@Table(name = "sys_role")
public class Role extends BaseEntity implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 角色代码
	 */
	@Column(length = 32)
	private String roleNo;
	/**
	 * 角色名称
	 */
	@Column(length = 200)
	private String roleName;
	/**
	 * 角色类型
	 */
	@Column(length = 32)
	private String roleType;
	/**
	 * 是否启用
	 */
	private Byte isActive;

	/**
	 * 所属组织机构
	 */
	@ManyToOne()
	@JoinColumn(name = "orgId")
	private Organize organize;
	/**
	 * 角色和用户角色表之间的关系配置，一对多，由用户角色表来维护他们之间的关系
	 */
	@OneToMany(mappedBy = "role", fetch = FetchType.LAZY)
	private List<UserRole> users;
	/**
	 * 角色和权限之间的关系，角色和权限是一对多的关系，关系由关联表来维护
	 */
	@OneToMany(mappedBy = "role", fetch = FetchType.LAZY)
	@Cascade(CascadeType.DELETE)
	private List<FunctionAuthority> auths;
	@OneToMany(mappedBy = "role", fetch = FetchType.LAZY)
	@Cascade(CascadeType.DELETE)
	private List<PageElementAuth> pageAuth;

	/**
	 * @return the pageAuth
	 */
	public List<PageElementAuth> getPageAuth() {
		return pageAuth;
	}

	/**
	 * @param pageAuth
	 *            the pageAuth to set
	 */
	public void setPageAuth(List<PageElementAuth> pageAuth) {
		this.pageAuth = pageAuth;
	}

	public String getRoleNo() {
		return roleNo;
	}

	public void setRoleNo(String roleNo) {
		this.roleNo = roleNo;
	}

	/**
	 * @return the roleName
	 */
	public String getRoleName() {
		return roleName;
	}

	/**
	 * @param roleName
	 *            the roleName to set
	 */
	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	/**
	 * @return the roleType
	 */
	public String getRoleType() {
		return roleType;
	}

	/**
	 * @param roleType
	 *            the roleType to set
	 */
	public void setRoleType(String roleType) {
		this.roleType = roleType;
	}

	/**
	 * @return the users
	 */
	public List<UserRole> getUsers() {
		return users;
	}

	/**
	 * @param users
	 *            the users to set
	 */
	public void setUsers(List<UserRole> users) {
		this.users = users;
	}

	/**
	 * @return the auths
	 */
	public List<FunctionAuthority> getAuths() {
		return auths;
	}

	/**
	 * @param auths
	 *            the auths to set
	 */
	public void setAuths(List<FunctionAuthority> auths) {
		this.auths = auths;
	}

	public Organize getOrgnize() {
		return organize;
	}

	public void setOrgnize(Organize organize) {
		this.organize = organize;
	}

	/**
	 * @return the isActive
	 */
	public Byte getIsActive() {
		return isActive;
	}

	/**
	 * @param isActive
	 *            the isActive to set
	 */
	public void setIsActive(Byte isActive) {
		this.isActive = isActive;
	}

	/**
	 * @return the organize
	 */
	public Organize getOrganize() {
		return organize;
	}

	/**
	 * @param organize
	 *            the organize to set
	 */
	public void setOrganize(Organize organize) {
		this.organize = organize;
	}
}
